<?php

namespace app\langjinmobile\controller;
//导入基类
use think\Controller;
use think\facade\Cache;
use think\Db;
use app\common\model\GoodsCategory as goodscategoryModel;
use app\common\model\Goods as goodsModel;
class Classify extends Controller 
{
	public function index(){
		$category = goodscategoryModel::where(['is_show'=>1])->order('sort_order asc')->select();
		$max_cat_id =   request()->param('cat_id');
		if(empty($max_cat_id)){
			$max_cat_id = goodscategoryModel::where(['is_show'=>1])->order('sort_order asc')->order('cat_id asc')->value('cat_id');
		}
		$goods_info = goodsModel::where(['cat_id'=>$max_cat_id])->where('amount','>',0)->where('bis_id','<>',0)->limit(5)->order('id desc')->select();
		foreach($goods_info as $key=>$row){
			$img = explode(',',$goods_info[$key]['img1']);
			$goods_info[$key]['img1'] = $img[0];
		}
		$this->assign('category',$category);
		$this->assign('max_cat_id',$max_cat_id);
		$this->assign('goods_info',$goods_info);
		return $this->fetch();
	}

}